package com.carworld.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class DicUtil {

	public static final int PAGE_SIZE = 10;
	
	public static final String CACHE_SYSUSER = "sysUser";   //9.22Horace
	
	public static final String CACHE_USER_CARD = "userCard";   //9.27Horace
	
	public static final String CACHE_ORDER_SHOP = "ordershop";   //10.06 Bsea
	
	public static final String CACHE_SPARES_ALL = "sparesall";   //12.28 Bsea
	
	public static final String CACHE_SHOP_RECORD = "shopRecord";   //10.06 Bsea
	
	public static final String CACHE_USER_RESERVE = "userReserve";   //10.15 Horace
	
	public static final String CACHE_SYS_OFFICE = "sysOffice";   //10.15 Horace
	
	public static final String CACHE_DIVIDEND_RECORD = "dividendRecord";   //10.19 Horace
	
	public static final String CACHE_USER_WITHDRAWAL = "userWithdrawal";   //10.25 Horace
	
	public static final String CACHE_CARD = "card";   //11.3 Horace
	
	public static final String CACHE_CARD_SET_MEAL = "cardSetMeal";   //11.3 Horace
	
	public static final String CACHE_MEAL = "meal";   //11.16 Horace
	
	public static final String CACHE_PRINT_TOKEN = "printToken";   //4.7 Horace
	
	public static final String CACHE_PRINT_REFRESH_TOKEN = "refreshToken";   //4.7 Horace
	
	public static final String CACHE_RECHARGE = "recharge";   //4.19 Horace
	
	
	public static Map<Integer, Integer> GIVING_MAP = null;

	public static Map<Integer, Integer> getMap() {
		if (null == GIVING_MAP) {
			GIVING_MAP = new HashMap<Integer, Integer>();
			GIVING_MAP.put(3000, 0);
			GIVING_MAP.put(5000, 1000);
			GIVING_MAP.put(10000, 2500);
			GIVING_MAP.put(20000, 6000);
			GIVING_MAP.put(50000, 20000);
			GIVING_MAP.put(100000, 50000);
		}
		return GIVING_MAP;
	}

	public static int getRan(int amount) {
		int min = (int) Math.floor(amount / 10);
		int max = amount * 2;
		int res = min;
		Random random = new Random();
		do {
			res = random.nextInt(max + 1);
		} while (res >= amount / 2 && res % 7 != 0);
		return res;
	}
}
